package com.zrfintech.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.zrfintech.common.pojo.BasePageEntity;
import com.zrfintech.domain.MgMenu;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MgMenuRepo extends MgMenuRepoI {
    public List<MgMenu> getByMenuCodeList(List<String> menuCodeList) {
        if (CollectionUtils.isEmpty(menuCodeList)) {
            return Lists.newArrayList();
        }
        QueryWrapper<MgMenu> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(MENU_CODE_COLUMN, menuCodeList);
        queryWrapper.orderByAsc(MENU_SORT_COLUMN);
        return dao.selectList(queryWrapper);
    }

    public Page<MgMenu> pageList(BasePageEntity basePageEntity) {
        return pageList(basePageEntity, null);
    }

    public MgMenu getByMenuCode(String menuCode) {
        QueryWrapper<MgMenu> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(MENU_CODE_COLUMN, menuCode);
        return dao.selectOne(queryWrapper);
    }
}
